package org.jeecg.modules.rental.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.jeecg.modules.rental.entity.RentalFence;
import org.jeecg.modules.rental.mapper.RentalFenceMapper;
import org.jeecg.modules.rental.service.IRentalFenceService;
import org.springframework.cache.CacheManager;
import org.springframework.stereotype.Service;

/**
 * @Description: 电子围栏
 * @Author: sean
 * @Date:   2024-11-19
 * @Version: V1.0
 */
@Service
@RequiredArgsConstructor
public class RentalFenceServiceImpl extends ServiceImpl<RentalFenceMapper, RentalFence> implements IRentalFenceService {

    private final CacheManager cacheManager;

    @Override
    public IPage<RentalFence> selectJoinPage(Page page, RentalFence rentalFence) {
        IPage<RentalFence> pageList = baseMapper.selectJoinPage(page,rentalFence);
        if(pageList!=null && pageList.getRecords().size()>0){
            // TODO 后续优化部门缓存
//            Cache deptCache = cacheManager.getCache(CacheConstant.SYS_DEPARTS_CACHE);
//            pageList.getRecords().stream().forEach(item->{
//                SysDepartVO sysDepartVO = deptCache.get(item.getSysOrgCode(), SysDepartVO.class);
//                item.setSysOrgName(sysDepartVO.getDepartName());
//            });
        }
        return pageList;
    }
}
